#include<bits/stdc++.h>
#define lowbit(x) ((x)&-(x))
using namespace std;
const int mod = 998244353;
long long qmi(long long a,int b)
{
	long long res = 1;
	while(b)
	{
		if(b & 1) (res *= a) %= mod;
		(a *= a) %= mod;
		b >>= 1;
	}
	return res;
}
int n;
int t[300011];
void add(int p)
{
	while(p <= n)
		t[p]++,p += lowbit(p);
}
int ask(int p)
{
	int res = 0;
	while(p)
		res += t[p],p -= lowbit(p);
	return res;
}
int a[300011];
long long f[303][303][303],s[303][303],g[303][303];
void Calc(int k)
{
	long long ans = 0;
	for(int i = 1;i <= n;i++)
		for(int j = 1;j <= n;j++) if(a[i] < a[j])
			ans += f[k][i][j];
	cout << ans % mod << "\n";
}
int k,q;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	freopen("random.in","r",stdin);
	freopen("random.out","w",stdout);
	cin >> n >> k >> q;
	for(int i = 1;i <= n;i++)
		cin >> a[i];
	if(k == 0)
	{
		long long res = 0;
		for(int i = n;i;i--)
			res += ask(a[i]),add(a[i]);
		cout << res;
	}
	for(int i = 2;i <= n;i++)
		for(int j = 1;j < i;j++)
			f[0][i][j] = 1;
	long long ni = qmi(n * (n - 1) / 2,mod - 2);
	for(int o = 1;o <= k;o++)
	{
		int l = o - 1;
		for(int i = 1;i <= n;i++)
		{
			for(int j = 1;j <= n;j++)
				s[l][i] += f[l][i][j];
			s[l][i] = s[l][i] % mod * ni % mod;
		}
		for(int j = 1;j <= n;j++)
		{
			for(int i = 1;i <= n;i++)
				g[l][j] += f[l][i][j];
			g[l][j] = g[l][j] % mod * ni % mod;
		}
		for(int i = 1;i <= n;i++)
			for(int j = 1;j <= n;j++) if(i != j)
			{
				f[o][i][j] = f[o - 1][i][j] * ((n - 2) * (n - 3) / 2 + mod - 2) % mod * ni % mod;
				f[o][i][j] = (f[o][i][j] + f[o - 1][j][i] * ni) % mod;
				f[o][i][j] = (f[o][i][j] + s[o - 1][i] + g[o - 1][j]) % mod;
			}
	}
	Calc(k);
	for(int i = 1;i <= q;i++)
	{
		int x,y;
		cin >> x >> y;
		swap(a[x],a[y]);
		Calc(k - i);
	}
	return 0;
}
